#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef char BTDataType;

typedef struct BinaryTree {
    BTDataType data;
    struct BinaryTree *left;
    struct BinaryTree *right;
}BinaryTree;

// 二叉树中序遍历
void InOrder(BinaryTree *root) {
    if (root == NULL) {
        return;
    }
    InOrder(root->left);
    printf("%c ", root->data);
    InOrder(root->right);
}

BinaryTree *BinaryCreate(BTDataType *nums, int *size) {
    if (nums[*size] == '#' || nums[*size] == '\0') {
        return NULL;
    }
    BinaryTree *root = (BinaryTree *)malloc(sizeof(BinaryTree));
    root->data = nums[*size];
    (*size)++;
    root->left = BinaryCreate(nums, size);
    (*size)++;
    root->right = BinaryCreate(nums, size);
    return root;
}

int main() {
    BTDataType nums[101];
    scanf("%s", nums);
    int size = 0;
    BinaryTree *root = BinaryCreate(nums, &size);
    InOrder(root);
    return 0;
}


